package org.gpp.proj1.demo.projectile;

import org.gpp.proj1.particle.Missile;

import com.jme.app.AbstractGame;
import com.jme.app.SimpleGame;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;

/**
 * 
 * @author Gustavo de Farias
 */
public class TestMissile extends SimpleGame {
	
	Missile m;

	public static void main(String[] args) {
		TestMissile app = new TestMissile();
		app.setDialogBehaviour(AbstractGame.FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);
		app.start();
	}
	
	protected void simpleInitGame() {
		display.setTitle("Missile Test");
		
		cam.setLocation(new Vector3f(13, 0, 8));
		cam.lookAt(new Vector3f(0, 0, 8), new Vector3f(0,1,0));

		KeyBindingManager.getKeyBindingManager().set("fire", KeyInput.KEY_SPACE);
		KeyBindingManager.getKeyBindingManager().set("explode", KeyInput.KEY_RETURN);
		
		
		this.m = new Missile();
		
		rootNode.attachChild(m.getMissileNode());
	}
	
	@Override
	protected void simpleUpdate() {
		super.simpleUpdate();
		
		if (KeyBindingManager.getKeyBindingManager().isValidCommand("fire",	false)) {
			this.m.activate();
		}
		else if (KeyBindingManager.getKeyBindingManager().isValidCommand("explode", false)) {
			this.m.explode();
		}
	}
}